var app = getApp();
Page({
  data: {
  },

  onLoad: function() {
    var store_id = wx.getStorageSync("store_id");
    console.log(store_id)
    if(!store_id){
      app.showToast("请登录小程序")

    }else{
      this.setData({
        store_id:wx.getStorageSync("store_id")
      })
      this.getStoreInfo();
    }
  },

  getStoreInfo:function(){
    var t = this;
    app.visit("account/getStoreInfo", {
      store_id:t.data.store_id
    }, "", function(c) {
      console.log(c)
      if(0 == c.code){
        t.setData({
          info:c.data.info,
          fr_name:c.data.info.fr_name,
          kaihuhang:c.data.info.kaihuhang,
          tx_zhanghu:c.data.info.tx_zhanghu,
          tx_mobile:c.data.info.tx_mobile,
        })
      }else{
        app.showToast(c.msg)
      }
    })
  },

  setXZ:function(e){
    var fr_name = e.detail.value;
    console.log(fr_name)
    this.setData({
      fr_name:fr_name
    })
  },

  setKaihuhang:function(e){
    var kaihuhang = e.detail.value;
    console.log(kaihuhang)
    this.setData({
      kaihuhang:kaihuhang
    })
  },

  setTxZhanghu:function(e){
    var tx_zhanghu = e.detail.value;
    console.log(tx_zhanghu)
    this.setData({
      tx_zhanghu:tx_zhanghu
    })
  },

  setTxMobile:function(e){
    var tx_mobile = e.detail.value;
    console.log(tx_mobile)
    this.setData({
      tx_mobile:tx_mobile
    })
  },

  tijiao:function(){
    var t = this;
    var store_id = wx.getStorageSync("store_id");
    if(!store_id){
      app.showToast("请登录小程序")
    }else{
      wx.showModal({
        title: '提示',
        content: '确认修改提现账户吗',
        success: function (res) {
          if (res.confirm) {
            var phoneReg = /(^1[3|4|5|6|7|8|9]\d{9}$)|(^09\d{8}$)/;
            //电话
            if (!phoneReg.test(t.data.tx_mobile)) {
              app.showToast('请输入有效的手机号码！')
              return false;
            }
            app.visit("account/setTiXianZhangHu", {
              store_id:store_id,
              fr_name:t.data.fr_name,
              kaihuhang:t.data.kaihuhang,
              tx_zhanghu:t.data.tx_zhanghu,
              tx_mobile:t.data.tx_mobile,
            }, "", function(c) {
              console.log(c)
              if(0 == c.code){
                wx.showToast({
                  title: c.msg,
                  icon: 'none',
                  duration: 3000,
                  success:function () {
                   wx.navigateBack();
                  }
                })
              }else{
                app.showToast(c.msg)
              }
            })
          } else {//这里是点击了取消以后
            console.log('用户点击取消')
          }
        }
      })
    }
  }

})